/*60 + 10 pts*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10, MAXL = 1e6 + 10;

struct Car {
    int l, r;
};
Car mp[MAXN];
int dp[3000 + 10][3000 + 10];//mi, check i = min n
int p[MAXL], pre[MAXL];
int n, m, l;

bool cmp(Car x, Car y)
{
    return x.l < y.l;
}
/*
int dfs(int d, int id)
{
    if (dp[d][id] != -1) return dp[d][id];
    if (d > n) return 0;
    int idd = lower_bound(b + 1, b + 1 + n, p[d]) - b;
    for ()

}
*/
int hx[MAXN];
/*
void dfs(d, k)
{
    if (d > n)
    {
        for (int i = 1; i <= n; ++i)
        maxnk = max(maxnk, k);
    }
    dfs(d + 1, k + 1);
    for (int i = 1; i <= n; ++i)
        if (mp[i].l <= m[d] && m[d] <= mp[l].r)
            hx[i] = 1;
    dfs(d + 1, k);
    for (int i = 1; i <= n; ++i)
        if (mp[i].l <= m[d] && m[d] <= mp[l].r)
            hx[i] = 0;
}
*/
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int T;
    cin >> T;
    while (T--)
    {
        long double vm;//vm: v_ma
        bool judge = true;
        cin >> n >> m >> l >> vm;
        for (int i = 1; i <= n; ++i)
        {
            long double d, v, a;
            cin >> d >> v >> a;
            if (a) judge = false;
            if (!a)
            {
                if (v > vm)
                {
                    mp[i].l = d;
                    mp[i].r = l;
                }
                if (v <= vm)
                {
                    mp[i].l = 0;
                    mp[i].r = 0;
                }
                continue;
            }
            long double x = (vm * vm - v * v) / (2.0 * a);
            int jd = 0;//jingdu
            if (x == (long long)(x)) jd = 1;
            if (v > vm)
            {
                if (a > 0)
                {
                    mp[i].l = d;
                    mp[i].r = l;
                }
                if (a < 0)
                {
                    mp[i].l = d;
                    mp[i].r = min(l, (int)(d + floor(x) - jd));
                }
            }
            if (v <= vm)
            {
                if (a < 0)
                {
                    mp[i].l = 0;
                    mp[i].r = 0;
                }
                if (a > 0)
                {
                    mp[i].l = d + ceil(x) + jd;
                    mp[i].r = l;
                }
            }
        }
        for (int i = 1; i <= m; ++i)
            cin >> p[i];
        /*
        for (int i = 1; i <= n; ++i)
            cout << i << ": " << mp[i].l << " - " << mp[i].r << endl;
        */
        int cnt = 1;
        pre[0] = 0;
        for (int i = 1; i <= l; ++i)
        {
            pre[i] = pre[i - 1];
            if (p[cnt] == i)
            {
                pre[i]++;
                if (cnt < m) cnt++;
            }
        }
        int ans1 = 0;
        for (int i = 1; i <= n; ++i)
            if (mp[i].r)
                if (pre[mp[i].r] - pre[mp[i].l - 1])
                    ans1++;
        cout << ans1 << ' ';
        if (judge)
        {
            cout << m - 1 << endl;
            continue;
        }
    }
    return 0;
}
/*
1
9 10 136382 369
54507 977 605
3911 760 -6
40194 861 -4
51022 665 -2
80430 821 -5
85729 821 -7
2895 754 -2
86004 904 -1
345 675 -1
10006 27479 38319 42148 48211 85717 87680 114851 121264 136382

9
*/
